<?php
/* --------------------------------------------------------------
   admin_leftboxes.php 2009-07-15 gambio
   Gambio GmbH
   http://www.gambio.de
   Copyright (c) 2009 Gambio GmbH
   Released under the GNU General Public License (Version 2)
   [http://www.gnu.org/licenses/gpl-2.0.html]
   --------------------------------------------------------------
*/
?><?php

if(defined('_GM_VALID_CALL') === false) die('x0');
if($_SESSION['customers_status']['customers_status_id'] != 0) die('x0');

function gm_set_leftboxes_status($customers_id, $box_key, $box_status)
{
	$customers_id = addslashes($customers_id);
	$box_key 			= addslashes($box_key);
	$box_status 	= addslashes($box_status);
	
	xtc_db_query('
		DELETE FROM gm_admin_boxes
		WHERE
			customers_id 	= "'. $customers_id .'" AND
			box_key			 	= "'. $box_key			.'"
	');
	
	xtc_db_query('
		INSERT INTO gm_admin_boxes
		SET
			customers_id 	= "'. $customers_id .'",
			box_key			 	= "'. $box_key			.'",
			box_status		= "'. $box_status		.'"
	');
}


$act 		 		= $_GET['act'];
$box_key 		= addslashes($_GET['box_key']);
$box_status = addslashes($_GET['box_status']);

switch($act)
{
	case 'get_closed_boxes':
		$result = xtc_db_query('
			SELECT box_key
			FROM gm_admin_boxes
			WHERE
				customers_id 	= "'.$_SESSION['customer_id'].'" AND
				box_status		= "0"
		');
		$out = '';
		while(($row = xtc_db_fetch_array($result) )) 
		{
			$out .= '"'. $row['box_key'] .'",';
		}
		$out = substr($out, 0, strlen($out) - 1);
		$out = strip_tags($out);
		$out = '{"box_keys" : ['.$out.']}';
		echo $out;
		break;
	
	case 'save_box_status':
		gm_set_leftboxes_status($_SESSION['customer_id'], $box_key, $box_status);
		break;
		
		
	default:
}




?>